﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Text;
using Maticsoft.DBUtility;
using Utils;
using System.Collections.Specialized;
using Maticsoft.Model;


public partial class team_current : FBasePage
{
    // Fields
    public string strCityName = "";

    // Methods
    private void initPage()
    {
        int num;
        string where = " Begin_time <= getdate() and getdate() <= End_time  ";
        if (base.CurrentCity != null)
        {
            where = where + " and City_id=" + base.CurrentCity.Id;
            this.strCityName = base.CurrentCity.Name;
        }
        if ((base.Request["gid"] != null) && (base.Request["gid"].ToString() != ""))
        {
            where = where + " and Group_id=" + base.Request["gid"].ToString();
        }
        if ((base.Request["id"] != null) && (base.Request["id"].ToString() != ""))
        {
            where = where + " and id=" + base.Request["id"].ToString();
        }
        Team team = new Team();
        StringBuilder builder = new StringBuilder();
        DataSet set = DbHelperSQL.Page(8, this.pager.CurrentPageIndex, "Team", where, " Sort_order  desc", "*", out num);
        if ((set.Tables.Count > 0) && (set.Tables[0].Rows.Count > 0))
        {
            for (int i = 0; i < set.Tables[0].Rows.Count; i++)
            {
                DataRow row = set.Tables[0].Rows[i];
                string currency = "";
                int num3 = 0;
                if (base.ASSystem != null)
                {
                    currency = base.ASSystem.Currency;
                    num3 = int.Parse(float.Parse(base.ASSystem.Moneysave.ToString()).ToString());
                }
                builder.Append("<li class=\" first\">");
                builder.Append("<p class=\"time\">" + DateTime.Parse(row["Begin_time"].ToString()).ToString("yyyy-MM-dd").ToString() + "</p>");
                builder.Append("<h4><a href=\"/team.aspx?id=" + row["id"].ToString() + "\" title=\"" + row["Title"].ToString() + "\" target=\"_blank\">" + row["Title"].ToString() + "</a></h4>");
                builder.Append("<div class=\"pic\">");
                builder.Append("<div class=\"\"></div>");
                builder.Append("<a href=\"/team.aspx?id=" + row["id"].ToString() + "\" title=\"" + row["Title"].ToString() + "\" target=\"_blank\"><img alt=\"" + row["Title"].ToString() + "\" src=\"" + row["Image"].ToString() + "\" width=\"200\" height=\"121\"></a>");
                builder.Append("</div>");
                builder.Append("<div class=\"info\">");
                builder.Append("<p class=\"total\"><strong class=\"count\">" + row["Now_number"] + "</strong>人购买</p>");
                string[] strArray = new string[] { "<p class=\"price\">原价：<strong class=\"old\"><span class=\"money\">\x00a5</span>", row["Market_price"].ToString(), "</strong><br />折扣：<strong class=\"discount\">", Convert.ToString((float)(float.Parse(row["Team_price"].ToString()) / float.Parse(row["Market_price"].ToString()))), "折</strong><br />现价：<strong><span class=\"money\">\x00a5</span>", row["Team_price"].ToString(), "</strong><br />节省：<strong><span class=\"money\">\x00a5</span>", (float.Parse(row["Market_price"].ToString()) - float.Parse(row["Team_price"].ToString())).ToString(), "</strong><br /></p>" };
                builder.Append(string.Concat(strArray));
                builder.Append("</div>");
                if (num3 == 1)
                {
                    builder.Append("<div id=\"info_a\">共为用户节省:<strong class=\"count\">" + ((float.Parse(row["Market_price"].ToString()) - float.Parse(row["Team_price"].ToString())) * float.Parse(row["Now_number"].ToString())) + "</strong></div>");
                }
                builder.Append("</li>");
            }
        }
        this.ltTeam.Text = builder.ToString();
        this.pager.RecordCount = num;
    }

    protected override void OnLoad(EventArgs e)
    {
        base.OnLoad(e);
        if (!this.Page.IsPostBack)
        {
            this.initPage();
        }
    }

    protected void pager_PageChanged(object sender, EventArgs e)
    {
        this.initPage();
    }

}